using System;
using MonoTouch.Foundation;
using MonoTouch.ObjCRuntime;

namespace Bonjour
{
	[BaseType (typeof (NSObject))]
	interface NSNetServiceBrowser
	{
		// Properties
		
		[Wrap ("WeakDelegate")]  
		NSNetServiceBrowserDelegate Delegate { get; set; }  

		[Export ("delegate", ArgumentSemantic.Assign)][NullAllowed]
		NSObject WeakDelegate { get; set; }
		
		// Instance Methods
		
		[Export ("removeFromRunLoop:forMode:")]
		void RemoveFromRunLoop(NSRunLoop runLoop, NSString runLoopMode);
		
		[Export ("scheduleInRunLoop:forMode:")]
		void ScheduleInRunLoop(NSRunLoop runLoop, NSString runLoopMode);
		
		[Export ("searchForBrowsableDomains")]
		void SearchForBrowsableDomains();
		
		[Export ("searchForRegistrationDomains")]
		void SearchForRegistrationDomains();
		
		[Export ("searchForServicesOfType:inDomain:")]
		void SearchForServicesOfType(NSString serviceType, NSString domainName);
		
	}
	
	[BaseType (typeof (NSObject))]  
   	interface NSNetService
	{
		
		// Class Methods
		
		[Static, Export ("dataFromTXTRecordDictionary:")]
		NSData DataFromTXTRecordDictionary(NSDictionary txtDictionary);
		
		[Static, Export ("dictionaryFromTXTRecordData:")]
		NSDictionary DictionaryFromTXTRecordData(NSData txtData);
		
		// Constructors
		
		[Export ("initWithDomain:type:name:")]  
   		IntPtr Constructor (string domain, string type, string name);
		
		[Export ("initWithDomain:type:name:port:")]  
   		IntPtr Constructor (string domain, string type, string name, int port);
		
		// Instance Methods
		
		[Export ("addresses")]
		NSData[] Addresses { get; }
		
		[Export ("domain")]
		NSString Domain { get; } 
		
		[Wrap ("WeakDelegate")]  
		NSNetServiceDelegate Delegate { get; set; }  

		[Export ("delegate", ArgumentSemantic.Assign)][NullAllowed]
		NSObject WeakDelegate { get; set; }
		
		[Export ("getInputStream:outputStream:")]
		bool GetInputStreamAndOutputStream(NSInputStream inputStream, NSOutputStream outputStream);
		
		[Export ("hostName")]
		NSString HostName { get; }
		
		[Export ("name")]
		NSString Name { get; }
		
		[Export ("port")]
		int Port { get; }
		
		/// <summary>
		/// Attempts to advertise the receiver’s on the network.
		/// </summary>
		[Export ("publish")]  
		void Publish();
		
		[Export ("publishWithOptions:")]
		void Publish(NSNetServiceOptions serviceOptions);
		
		[Export ("removeFromRunLoop:forMode:")]
		void RemoveFromRunLoop(NSRunLoop aRunLoop, NSString mode);
		
		[Export ("resolveWithTimeout:")]
		void Resolve(double timeout);
		
		[Export ("scheduleInRunLoop:forMode:")]
		void ScheduleInRunLoop(NSRunLoop aRunLoop, NSString mode);
		
		[Export ("startMonitoring")]  
		void StartMonitoring();
		
		[Export ("stop")]  
		void Stop();
		
		[Export ("stopMonitoring")]  
		void StopMonitoring();
		
		[Export ("TXTRecordData")]
		NSData TXTRecordData { get; set; }
		
		[Export ("type")]
		NSString Type { get; }
   	}
	
	[BaseType (typeof (NSObject))]
	[Model]
	interface NSNetServiceBrowserDelegate {
		
		[Export ("netServiceBrowser:didFindDomain:moreComing:")]
		void FoundDomain (NSNetServiceBrowser netServiceBrowser, NSString domainName, bool moreDomainsComing);
		
		[Export ("netServiceBrowser:didFindService:moreComing:")]
		void FoundService (NSNetServiceBrowser netServiceBrowser, NSNetService netService, bool moreServicesComing);
		
		[Export ("netServiceBrowser:didNotSearch:")]
		void SearchFailed (NSNetServiceBrowser netServiceBrowser, NSDictionary errorInfo);
		
		[Export ("netServiceBrowser:didRemoveDomain:moreComing:")]
		void DomainRemoved (NSNetServiceBrowser netServiceBrowser, NSString domainName, bool moreServicesComing);
		
		[Export ("netServiceBrowser:didRemoveService:moreComing:")]
		void ServiceRemoved (NSNetServiceBrowser netServiceBrowser, NSNetService netService, bool moreServicesComing);
		
		[Export ("netServiceBrowserDidStopSearch:")]
		void SearchStopped (NSNetServiceBrowser netServiceBrowser);
		
		[Export ("netServiceBrowserWillSearch:")]
		void WillSearch (NSNetServiceBrowser netServiceBrowser);
	}
	
	[BaseType (typeof (NSObject))]
	[Model]
	interface NSNetServiceDelegate {
		
		[Export ("netService:didNotPublish:")]
		void FailedToPublish (NSNetService sender, NSDictionary errorDict);
		
		[Export ("netService:didNotResolve:")]
		void FailedToResolve (NSNetService sender, NSDictionary errorDict);
		
		[Export ("netService:didUpdateTXTRecordData:")]
		void UpdatedTXTRecordData (NSNetService sender, NSData data);
		
		[Export ("netServiceDidPublish:")]
		void Published (NSNetService sender);
		
		[Export ("netServiceDidResolveAddress:")]
		void ResolvedAddress (NSNetService sender);
		
		[Export ("netServiceDidStop:")]
		void Stopped (NSNetService sender);
		
		[Export ("netServiceWillPublish:")]
		void WillPublish (NSNetService sender);
		
		[Export ("netServiceWillResolve:")]
		void WillResolve (NSNetService sender);
	}
}
